package com.example.myapplication

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.myapplication.ui.ImageViewerScreen
import com.example.myapplication.update.AutoUpdateApp
import com.example.myapplication.util.PermissionCheckWrapper

class MainActivity : ComponentActivity() {
    private lateinit var autoUpdate: AutoUpdateApp

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()

        // 在Activity创建时初始化AutoUpdateApp
        autoUpdate = AutoUpdateApp(this)

        // 只在首次创建时检查更新
        if (savedInstanceState == null) {
            autoUpdate.checkForUpdate()
        }

        setContent {
//            Greeting("Android")
            PermissionCheckWrapper {
                ImageViewerScreen()
            }
        }
    }

    override fun onDestroy() {
        super.onDestroy()
    }

    @Preview(showBackground = true)
    @Composable
    fun GreetingPreview() {
        ImageViewerScreen()
    }

    // hello compose
    @Composable
    fun Greeting(name: String, modifier: Modifier = Modifier) {
        Text(
            text = "Hello $name!",
            modifier = modifier
        )
    }

}





